package agency.tango.materialintroscreen.animations.translations;

import java.io.IOException;

import ohos.agp.components.Component;
import ohos.global.resource.NotExistException;
import ohos.global.resource.WrongTypeException;

import agency.tango.materialintroscreen.ResourceTable;
import agency.tango.materialintroscreen.utils.LogUtil;
import agency.tango.materialintroscreen.animations.IViewTranslation;
import agency.tango.materialintroscreen.utils.DisplayUtils;

/**
 * @ProjectName: material-intro-screen-master
 * @Package: agency.tango.materialintroscreen.animations.translations
 * @ClassName: ExitDefaultTranslation
 * @Description: pageslider随着滑动 传入的控件的竖直方向位移动态改变实现类---页面滑出
 * @CreateDate: 2021/4/12 15:43
 * @UpdateDate: 2021/4/12 15:43
 * @UpdateRemark: 暂无
 * @Version: 1.0
 */
public class ExitDefaultTranslation implements IViewTranslation {
    @Override
    public void translate(Component view, float percentage) {
        try {
            int integer = view.getResourceManager().getElement(ResourceTable.Integer_y_offset).getInteger();
            int transPx = DisplayUtils.vp2px(view.getContext(), integer);
            view.setTranslationY(percentage * transPx);
        } catch (NotExistException | WrongTypeException | IOException e) {
            LogUtil.error(this.getClass().getSimpleName(), e.toString());
        }
    }
}
